package com.wanhe.base.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;


/**
 * 
 * @ClassName: AdapterViewHolder 
 * @Description: 适配器的ViewHolder封装
 * @author chaoxunYang
 * @date 2016年06月27日 上午10:31:02
 */
public class AdapterViewHolder {
	protected View mConvertView;
    protected ViewHolderUtil mViewHolderHelper;

    private AdapterViewHolder(ViewGroup parent, int layoutId) {
        this.mConvertView = LayoutInflater.from(parent.getContext()).inflate(layoutId, parent, false);
        this.mConvertView.setTag(this);
        this.mViewHolderHelper = new ViewHolderUtil(parent, this.mConvertView);
    }

    private AdapterViewHolder(ViewGroup parent, View itemView) {
        this.mConvertView = itemView;
        this.mConvertView.setTag(this);
        this.mViewHolderHelper = new ViewHolderUtil(parent, this.mConvertView);
    }
    public static AdapterViewHolder dequeueReusableAdapterViewHolder(View convertView, ViewGroup parent, int layoutId) {
        return convertView == null?new AdapterViewHolder(parent, layoutId):(AdapterViewHolder)convertView.getTag();
    }

    public static AdapterViewHolder dequeueReusableAdapterViewHolder(View convertView, ViewGroup parent, View itemView) {
        return convertView == null?new AdapterViewHolder(parent, itemView):(AdapterViewHolder)convertView.getTag();
    }
    public ViewHolderUtil getViewHolderHelper() {
        return this.mViewHolderHelper;
    }

    public View getConvertView() {
        return this.mConvertView;
    }
}
